<template>
	<view>
		<view class="top_box" :style="{'paddingTop':SystemTop}">
			<view class="top">
				<u-image width="40" height="40" :src="back" @click="goBack"></u-image>
				<view class="line"></view>
				<u-image width="40" height="40" :src="home" @click="goIndex"></u-image>
			</view>
			<view class="top_title">
				{{title}}
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		props: {
			urlBack: {
				default: '',
				SystemTop:'',
				required: false
			},
			title: {
				default: '',
				required: true
			},
		},
		data() {
			return {
				height:'',
				home: require('@/static/icon/nav_back _ home@2x.png'),
				back: require('@/static/icon/nav_back _ parent@2x.png'),
			}
		},
		onReady() {
			this.Iswechat()
		},
		methods: {
			Iswechat(){
				// 获取微信胶囊的位置信息 width,height,top,right,left,bottom
				const custom = wx.getMenuButtonBoundingClientRect().top || 20
				const height = wx.getMenuButtonBoundingClientRect().height || 20
				this.SystemTop = custom + 'px'
				this.height = height + 'px'
			},
			goBack() {
				//this.$store.commit('SEARCHINPUT','') //清空search
				//console.log(this.urlBack);
				if (this.urlBack) {
					uni.redirectTo({
						url: this.urlBack
					});
					// uni.navigateTo({
					// 	url: this.urlBack
					// })
				} else {
					uni.navigateBack({
						delta: 1
					});
				}
				//this.$u.route() //返回按钮
				// uni.navigateBack({
				// 	delta: 1
				// });
				//console.log(1112);
				//this.$router.pu
			},
			goIndex() {
				//this.$store.commit('SEARCHINPUT','')  //清空search
				uni.switchTab({
					url: '/pages/index/index'
				});
			},
		},
	}
</script>

<style lang="scss" scoped>
	.top_box {
		padding-left: 20rpx;
		padding-top:10px;
		padding-bottom: 16rpx;
		display: flex;
		align-items: center;
		background-color: white;
		//position: fixed;
		//z-index: 971;
		background-color: #fff;
		width: 100%;

		//top: 200;
		.top {
			background: white;
			display: flex;
			border-radius: 50rpx;
			border: 1px solid rgba(151, 151, 151, 0.2);
			padding: 8rpx 20rpx;
			width: 170rpx;

			.line {
				width: 1px;
				height: 19px;
				margin: 0 20rpx;
				background: rgba(0, 0, 0, 0.2);
			}
		}

		.top_title {
			font-family: PingFang SC, PingFang SC;
			font-weight: bold;
			font-size: 32rpx;
			color: #000000;
			line-height: 38rpx;
			text-align: center;
			width: 100%;
			margin-right: 170rpx;
		}
	}
</style>